package com.ldq.imooc.springboot.boot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;

@RestController
public class GirlController {

    @Autowired
    private GirlRespository girlRespository;

    /**
     * 查询所有列表
     * @return
     */
    @GetMapping(value = "/girls")
    public List<Girl> girlList(){

        return girlRespository.findAll();
    }

    /**
     * 添加
     * @return
     */
    @PostMapping(value = "/girls")
    public Girl girlAdd(@RequestParam("age")Integer age,@RequestParam("cupSize")String cupSize){

        Girl girl = new Girl();
        girl.setAge(age);
        girl.setCupSize(cupSize);

        return girlRespository.save(girl);
    }
}
